OpenRoads Designer CONNECT Edition SDK Help

Browse all cells from cell library

The Below code snippet shows how to list all cells from cell libraries. This code browses all the cell libraries located at path "C:\ProgramData\Bentley\OpenRoads Designer CE 10.12\Configuration\Organization-Civil\_Civil Default Standards - Imperial\Cell", this is the default path and may change with the OpenRoads Designer version and workspace and workset user uses. The cell libraries have suffix as .cel

//Required References
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Bentley.MstnPlatformNET;


public List<string> BrowseAllCells()
        {
            List<string> cellList = new List<string>();

            try
            {
                //Get the cell library collection 
                CellLibraryCollection cellLibraryCollection = new CellLibraryCollection(CellLibraryOptions.DefaultAll);
                IEnumerator<CellLibraryInfo> cellLibraryInfos = cellLibraryCollection.GetEnumerator();

                //Iterate each cell library and add cell library name to list
                while (cellLibraryInfos.MoveNext())
                {
                    CellLibraryInfo cellLibraryInfo = cellLibraryInfos.Current;
                    if (!cellList.Contains(cellLibraryInfo.Name))
                        cellList.Add(cellLibraryInfo.Name);

                    //Cell library DGN file and name
                    DgnFile file = cellLibraryInfo.File;
                    String name = file.GetFileName();
                }
            }
            catch (Exception ex)
            {
                Trace.WriteLine(ex.Message);
            }
            return cellList;
        }